#include<iostream>
using namespace std;
int n, d;
int main()
{
	cin >> n >> d;
	int res = 0;
	for (int i = 0; i <= n && i * 3 <= d; i++) {
		int ans = d - i * 3;
		for (int j = 0; j <= n && j * 2 <= ans; j++) {
			int ans1 = d - i * 3 - j * 2;
			if (ans1 <= n) {
				res++;
			}
		}
	}
	cout << res << endl;
	return 0;
}